#include "stm32f10x.h" 
#include "oled.h"
#include "delay.h"
#include "ad.h"

uint16_t ad_value;
float voltage;

int main(void)
{
    OLED_Init();
    AD_Init();

    OLED_ShowString(1, 1, "AD_Value:");
    OLED_ShowString(2, 1, "Voltage:0.00V");

    while (1) 
    {
        ad_value = AD_GetValue();
        voltage = (float)ad_value / 4095 * 3.3;

        OLED_ShowNum(1, 10, ad_value, 4);
        OLED_ShowNum(2, 9, voltage, 1);
        OLED_ShowNum(2, 11, (uint16_t)(voltage * 100) % 100, 2);

        Delay_ms(100);
    }
}
